public class Priority {
    private final static int MAX_COUNT=1000;
    public static void main(String[] args) {
       Thread t1=new Thread(new Runnable() {
           @Override
           public void run() {
               //得到当前线程
               Thread t=Thread.currentThread();
               int priority=t.getPriority();//得到优先级
               for (int i = 0; i < MAX_COUNT; i++) {
                   System.out.println(t.getName()+"优先级"+priority);
               }

           }
       },"线程1");
      // t1.setPriority(10);
       //设置线程优先级
       t1.setPriority(Thread.MAX_PRIORITY);//设置了t1=10

        Thread t2=new Thread(new Runnable() {
            @Override
            public void run() {
                Thread t = Thread.currentThread();
                int priority = t.getPriority();//得到优先级
                for (int i = 0; i < MAX_COUNT; i++) {
                    System.out.println(t.getName() + "优先级" + priority);
                }
            }
        },"线程2");
        t2.setPriority(Thread.MIN_PRIORITY);
      Thread t3=new Thread(new Runnable() {
          @Override
          public void run() {
              Thread t = Thread.currentThread();
              int priority = t.getPriority();//得到优先级
              for (int i = 0; i < 1000; i++) {
                  System.out.println(t.getName() + "优先级" + priority);
              }
          }
      },"线程3");
      t3.setPriority(Thread.NORM_PRIORITY);
      t1.start();
      t2.start();
      t3.start();
    }
}
